home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / drivers / mscdex / testdrv / testdrv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-23  |  8.4 KB  |  278 lines

  1. /* FILE: testdrv.c
  2. **
  3. ** Copyright 1990 by Microsoft, All Rights Reserved.
  4. ** 
  5. ** of TESTDRV.EXE
  6. **
  7. ** Device Driver Test for MSCDEX compatible CD-ROM.
  8. ** Tests most aspects of direct driver requests detailed
  9. ** in Document 000080010-100-O00-1186 Microsoft Device
  10. ** Driver Specification.
  11. **
  12. ** NOTES: main, supporting procedures, global declarations
  13. **
  14. ** Created      7/15/90  - JYG
  15. ** Final (v1.0) 10/01/90 - JYG
  16. ** Created      12/06/91 -Siddhartha Roy 
  17. **
  18. */
  19.  
  20. #include"test.h"
  21.  
  22. /*
  23. ** Global Variable Declarations
  24. */
  25.  
  26. /*
  27. ** Many of the conventions here are non-standard
  28. **
  29. ** KEY: f  preceding a label is a flag (typically signed char)
  30. **      c  preceding a label is a counter (typically WORD)
  31. **      b  preceding a label is a byte (typically BYTE)
  32. **      p  preceding a label is a pointer (implied near without modifier)
  33. **      m  preceding a label is an array
  34. **      t  preceding an all upcase label is an index into an array
  35. **           of pointers to functions
  36. **      r  preceding an all upcase label is an index into an array
  37. **           of request structures
  38. **      sz preceding a label is a zero ('\0') terminated string
  39. **      i  preceding a label is a generic index
  40. **      l  preceding a label is a long
  41. **      ch preceding a label is a signed char
  42. **      lp preceding a label is a long pointer
  43. */
  44.  
  45. FLAG fInteract, fIgnoreCtrl, fWriteMedia, fRedbook, fRaw, fPrefetch,
  46.     fAudCtrl, fAudio, fInterleave, fEject, fUPC, fRedSector,
  47.     fHSGSector, fVerbose, fPrep, fSubInfo;    
  48.  
  49. BYTE    bInterSize,bInterSkip;      // Interleave Support
  50.  
  51. FILE    *pOutFile;                  // output file for hex dumps
  52. FILE    *pInFile;                   // input profile
  53.  
  54. WORD    cwWarnings, cwErrors;       // Error-Level Counters
  55. WORD    cwSkipped;                  // User Skipped Tests
  56. WORD    cwRequests;                 // Total number of requests
  57. WORD    iFirstDrvLetter;            // First Drive
  58. WORD    cwNumDrives;                // Number of Drives
  59. WORD    bDriveNumber;               // Current Drive Number
  60. WORD    cwAudioChan;                // Number of Audio Channels
  61. WORD    wDriveNum;                  // Drive Number
  62.  
  63. WORD    cwRedSectors,cwHSGSectors;  // Number of testing sectors
  64.  
  65. DWORD   mplHSGSector[10];           // HSG sectors to read
  66. DWORD   mplRedSector[10];           // Redbook sectors to read
  67.  
  68. char    *szStdPath;                 // Standard Path or from TESTDRV env
  69.     
  70. char    szDriverName[256];          // Driver Name
  71.  
  72. //
  73. // Local Functions
  74. //
  75.  
  76. static void UsageMsg(void);
  77. /*
  78. **  testdrv( Dev_List * )
  79. **  - main testing routine.
  80. */
  81. void    testdrv( drv )
  82. Dev_List    *drv;
  83. {
  84.     extern  FLAG fIgnoreCtrl;
  85.     extern  WORD cwRequests,cwErrors,cwWarnings;
  86.     
  87.     printf( "\n\tCODE\tSTATUS\tMESSAGE\n" );
  88.     printf( "\t=====\t======\t=======\n");
  89.     printf( "\n[NON-DISC SPECIFIC TESTS]\n" );
  90.  
  91.     (*mTestTbl[tINIT])( drv );
  92.     (*mTestTbl[tDEVSTAT])( drv );
  93.     (*mTestTbl[tRADDR])( drv );
  94.     (*mTestTbl[tRESET])( drv );
  95.     (*mTestTbl[tLOCKDOOR])( drv );
  96.     (*mTestTbl[tDRVBYTES])( drv );
  97.  
  98.     /*
  99.     **  The following test has been disabled.  For more thorough tests,
  100.     **  re-activate.  It tests 256 commands.
  101.     */
  102.  
  103.     // (*mTestTbl[tRESERVEDCMD])( drv );
  104.  
  105.     (*mTestTbl[tSECTORSIZE])( drv );
  106.     (*mTestTbl[tUPCCODE])( drv );
  107.     (*mTestTbl[tVOLSIZE])( drv );
  108.  
  109.     if ( fInteract ) 
  110.         (*mTestTbl[tEJECT])( drv );
  111.     
  112.     if ( fAudio )
  113.         (*mTestTbl[tAUDIODISK])( drv );
  114.  
  115.     if ( fIgnoreCtrl )
  116.         (*mTestTbl[tSECTORDUMP])( drv );
  117.     else
  118.         (*mTestTbl[tTESTCONTROL])( drv );
  119.  
  120.     printf( "\n\t%d - Errors\n\t%d - Warnings\n\t%d - Requests",
  121.         cwErrors,cwWarnings,cwRequests );
  122.     
  123.     exit( cwErrors );
  124.  
  125. }
  126.  
  127. static void UsageMsg()
  128. {
  129.     printf( "USAGE: TESTDRV [filename.pro] [/A] [/I] [/T]\n" );
  130.     printf( "\t/# - (where # is a number from 0-7) The drive unit number\n" );
  131.     printf( "\t/A - Attended Mode\n" );
  132.     printf( "\t/I - Ignore Control Disks\n" );
  133.     printf( "\t/T - Terse output (verbose is default)\n" );
  134.     printf( "\t[FILENAME] - Alternate Profile\n" );
  135.     printf( "\nThe location of sample archives is assumed to be the current directory, but" );
  136.     printf( "\nmay be specified by setting the TESTDRV environment variable." );
  137.     printf( "\n\nStatus Line Format:" );
  138.     printf( "\n<CODE>\t<STATUS>\t<COMMAND>:<COMMENT>\n" );
  139.     printf( "\nThe status field can be blank or:" );
  140.     printf( "\n\t*ERROR*  - High priority error, generated by the driver" );
  141.     printf( "\n\t-ERROR-  - Error, generated by this application" );
  142.     printf( "\n\tWARNING  - Unusual event, possibly hardware dependent" );
  143.     printf( "\n\tTESTING  - Announcement of a device request (verbose mode)\n" );
  144.     printf( "------------------------------------------------------------------------------\n" );
  145.     printf( "Note: In verbose mode, all requests made to the driver are noted on standard\n" );
  146.     printf( "output.  All requests will be followed by a translation of the returned\n" );
  147.     printf( "status bits combination, i.e. ERROR BUSY and DONE.\n" );
  148.     printf( "------------------------------------------------------------------------------\n" );
  149.     exit(2);
  150. }
  151.  
  152. /*
  153. ** main() does the Request line parsing, calls the setup and starts the
  154. ** test.
  155. */
  156.  
  157. #define PROFILE_STRING      "TESTDRV.pro"
  158.  
  159. void main( argc , argv )
  160. int argc;
  161. char    *argv[];
  162. {
  163.     extern FLAG fInteract,fIgnoreCtrl,fVerbose,fPrep;
  164.     extern WORD cwNumDrives;
  165.     extern char * szStdPath;
  166.     extern WORD wDriveNum;
  167.     
  168.     static char szDefProfile[] = PROFILE_STRING;
  169.     
  170.     Dev_List Dev_Tbl[26]; /** For a maximum of 26 drives **/
  171.     FILE *pInFile;
  172.     short n;
  173.     char *pchProfile;
  174.     char szFullPath[256];
  175.     
  176.     printf( "\n\tMicrosoft CD-ROM Device Driver Test, Version 1.0\n" );
  177.     printf( "\tCopyright 1990 by Microsoft Corp., All Rights Reserved.\n\n" );
  178.         
  179.     pchProfile  = szDefProfile;
  180.     fInteract   = FALSE;
  181.     fIgnoreCtrl = FALSE;
  182.     fVerbose    = TRUE;
  183.     fPrep       = FALSE;
  184.     wDriveNum   = 0;
  185.  
  186.     // Parse the command line out 
  187.  
  188.     for( n=1;n<argc;n++ ) {
  189.         if ( argv[n][0] == '/' || argv[n][0] == '-' ) {
  190.             switch ( toupper(argv[n][1]) ) {
  191.                 case 'A':     // attended testing
  192.                     fInteract = TRUE;
  193.                     break;
  194.                 case 'I':     // ignore control disks
  195.                     fIgnoreCtrl = TRUE;
  196.                     break;
  197.                 case 'T':      // no hex dumps
  198.                     fVerbose = FALSE;
  199.                     break;
  200.                 case 'P':      // prep mode
  201.                     fPrep = TRUE;
  202.                     break;
  203.  
  204.                 case '0': case '1': case '2': case '3':
  205.                 case '4': case '5': case '6': case '7':
  206.                     wDriveNum = argv[n][1]-'0';
  207.                     break;
  208.                 case '?': default:
  209.                     UsageMsg();
  210.                     break;
  211.                 }
  212.         } else if ( pchProfile == szDefProfile ) //Check user defined profile
  213.             pchProfile = argv[n];        // Yank it in
  214.             else UsageMsg();
  215.  
  216.     }
  217.  
  218.     // Check environment for profile pathname 
  219.  
  220.     if ((szStdPath = getenv("TESTDRV"))!=NULL)
  221.         sprintf(szFullPath,"%s\\%s",szStdPath,pchProfile);
  222.     else sprintf(szFullPath,"%s",pchProfile);
  223.  
  224. #ifdef DEBUG
  225. printf("PROFILE: %s\n",szFullPath);
  226. #endif
  227.  
  228.     if ( (pInFile = fopen( szFullPath,"r" ))==NULL )
  229.     {
  230.         printf( "Cannot open profile '%s'\n",szFullPath );
  231.         fatalError( "Exiting." );
  232.     }
  233.  
  234.     //
  235.     // Setup from file    
  236.     //
  237.         
  238.     setup( pInFile );
  239.  
  240.     //
  241.     // Locate drivers and store the information in Dev_Tbl
  242.     //
  243.         
  244.     find_drivers( Dev_Tbl );
  245.  
  246.     printf( "\n\tTESTING DRIVE %d\n",wDriveNum );   
  247.     if ( wDriveNum >= cwNumDrives )
  248.         fatalError( "Drive number out of range, Exiting." );
  249.  
  250.     //
  251.     // Is the driver valid?
  252.     //
  253.  
  254.     printf("\n\tVerifying Drive Name ...");
  255.       
  256.     if (_fstricmp((Dev_Tbl[wDriveNum].dev_addr)->sdevname,szDriverName)){
  257.             printf( "\n\tDrive Signature '%s' in profile does not match drive table.\n",
  258.                 szDriverName );
  259.        fatalError("Exiting");
  260.     }
  261.     printf(" Okay \n");
  262.     
  263.  
  264.  
  265.  
  266. #ifdef PREPARE
  267.  
  268.     if ( fPrep ) 
  269.         prepData( Dev_Tbl+wDriveNum );
  270.     else 
  271.     
  272. #endif
  273.  
  274.     testdrv( Dev_Tbl+wDriveNum );
  275.  
  276. }
  277.  
  278.